using System;
using Infrastructure.Data;
using Infrastructure.TestsCore.DemoData;

namespace Infrastructure.TestsCore.Helpers
{
    public class DatabaseHelper
    {

        public void DeleteAndCreateDatabase()
        {
            using (MainModuleUnitOfWork unitOfWork = new MainModuleUnitOfWork())
            {
                if (unitOfWork.Database.CreateIfNotExists()) { }
                else
                {
                    unitOfWork.Database.Delete();
                    unitOfWork.Database.Create();
                }
            }
        }

        public void InsertDemoData()
        {
            using (MainModuleUnitOfWork unitOfWork = new MainModuleUnitOfWork())
            {
                // Inserting partners in database
                var partnersCollection = new PartnersCollection().GetPartners();
                partnersCollection.ForEach(partner => unitOfWork.Partners.Add(partner));
                unitOfWork.SaveChanges();
            }

        }
    }
}